﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Security.Principal;
using System.IO;
using System.Threading;

namespace WordTestApp
{
    class Program
    {
        static string location = ConfigurationManager.AppSettings["Location"];
        static string driverPath = ConfigurationManager.AppSettings["Driverpath"];

        static void Main(string[] args)
        {
//            IntPtr token = IntPtr.Zero;
//            bool isSuccess = NetWorkConnection.LogonUser(username, domain, password,
//NetWorkConnection.LOGON32_LOGON_NEW_CREDENTIALS,
//NetWorkConnection.LOGON32_PROVIDER_DEFAULT, ref token);

            //Start Test 

            var filePath = string.Format(@"{1}\test{0}.docx", DateTime.Now.ToString("yyMMddHHmmss"),driverPath);
            StartWord.Start(filePath, location);
            //using (WindowsImpersonationContext person = new WindowsIdentity(token).Impersonate())
            //{
            //    File.Copy(tempData, filePath);
            //    person.Undo();
            //}
            Thread.Sleep(3000);
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
        }
    }
}
